package com.sky.controller.user;

import com.sky.constant.StatusConstant;
import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import com.sky.vo.DishVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("UserSetmealController")
@RequestMapping("/user/setmeal")
@Api(tags = "用户套餐管理")
@Slf4j
public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    @GetMapping("/list")
    @ApiOperation("根据分类id获取套餐列表")
    public Result<List<Setmeal>> list(@RequestParam Long categoryId) {
        log.info("根据分类ID {}获取套餐列表 ", categoryId);
        Setmeal setmeal = new Setmeal();
        setmeal.setCategoryId(categoryId);
        setmeal.setStatus(StatusConstant.ENABLE);
        List<Setmeal> setmealList = setmealService.selectSetmealsWithEableStatusByCategoryId(setmeal);
        return Result.success(setmealList);
    }

    @GetMapping("/dish/{id}")
    @ApiOperation("根据套餐id获取菜品列表")
    public Result<List<DishItemVO>> dish(@PathVariable("id") Long setmealId) {
        log.info("根据套餐ID {}获取菜品列表 ", setmealId);
        List<DishItemVO> dishList = setmealService.selectDishItemVOBySetmealId(setmealId);
        return Result.success(dishList);
    }

}
